$(() => {
  const user = JSON.parse(sessionStorage.getItem('user'))
  $('#avatarPreview').attr('src', user.avatar)
  $('#nickName').html(user.nickName)
  $('#logout').on('click', function () {
    const result = confirm('您确定要退出吗?')
    if (!result) {
      return
    }
    $.ajax({
      type: 'post',
      url: '/logout',
      success(res) {
        location.href = '/admin/login.html'
      },
      error() {
        alert('退出失败!')
      }
    })
  })

})
